home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 360 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  8.7 KB

  1. Path: hecate.umd.edu!ram
  2. From: ram@mbisgi.umd.edu (Ram Samudrala)
  3. Newsgroups: comp.infosystems.www.misc,comp.lang.misc,comp.lang.perl.misc,comp.lang.c
  4. Subject: Re: Perl vs. C (was Re: Unix or NT? Get a Mac!)
  5. Followup-To: comp.infosystems.www.misc,comp.lang.misc,comp.lang.perl.misc,comp.lang.c
  6. Date: 4 Jan 1996 19:57:43 GMT
  7. Organization: The Centre for Advanced Research in Biotechnology
  8. Message-ID: <4chbfn$68u@hecate.umd.edu>
  9. References: <4cgfp9$pje@hecate.umd.edu> <4ch1a5$fms@news.cerf.net>
  10. Reply-To: me@ram.org
  11. NNTP-Posting-Host: iris3.carb.nist.gov
  12. X-Newsreader: TIN [version 1.2 PL0]
  13.  
  14. GENUINE PROBLEM FROM THE ACM EAST CENTRAL REGIONAL PROGRAMMING CONTEST
  15. INCLUDED HERE.
  16.  
  17. Paul Phillips (paulp@nic.cerf.net) wrote:
  18.  
  19. >ANY from the last regional competition. 
  20.  
  21. This is the problem.  The regional contests are not on-line (first of
  22. all, I'm sick and home, and so I can't search the www).  I have my
  23. 1992 East-Central regional contest book in front of me.  They give you
  24. solutions.   Some of the solutions are only 50-100 lines in Pascal, so
  25. if you were good, then it can't take you more than 10-15 minutes.  The
  26. problems in the contest are more complicated than what I gave.  As I
  27. said, some of the problems were solved in 5 minutes.  Some took two
  28. hours. 
  29.  
  30. >it's like trying to argue with a Jesus freak.
  31.  
  32. Funny.  It's how I feel.  
  33.  
  34. >They give six problems and five hours -- and nobody has ever finished
  35. >all six problems (at least that's what we were told, and nobody did at
  36. >ours either.)
  37.  
  38. They must have dumbed it down then. <-: We had 8 problems in 5 hours,
  39. we did 5 (almost 7---it's a sad story doing with our inexperience),
  40. and the top two teams (we were 6/70) did do 6 problems.
  41.  
  42. >It would be trivial for even a modestly accomplished Perl programmer
  43. >to finish them all in that time span (and no, I won't test for your
  44. >benefit.  Believe it or don't.)
  45.  
  46. Then there's no validity for your comments.  Put up or shut up.
  47.  
  48. >You contrived an extremely short almost wholly algorithmic problem as
  49. >a comparison -- means nothing. 
  50.  
  51. I didn't contrive it---it was a practice problem for one such contest.
  52. But I did dig up the problems.  The problem descriptions are over a
  53. page. 
  54.  
  55. All right.  I've decided to be dumb enough and type in a description.
  56. Ignore any typos.  This is the SHORTEST (in terms of text) problem of
  57. the set which I'm just picking without even reading it (well, now I
  58. have).  This was one of the problems we did solve fast (it's fairly
  59. simple).   All the other problems are similar in nature.  The Pascal
  60. code for this is about 60 lines. Note that you will be tested on other
  61. inputs besides the example one.
  62.  
  63. -- PROBLEM G -- 
  64.  
  65. PUMP UP THE VOLUME
  66.  
  67. A particular part of the world has recently been experiencing a sudden
  68. and marked proliferation of pirate radio stations.  So much so, in
  69. fact, that a group of concerned nations have asked for your assistance
  70. pinpointing the source of the illegal transmissions.  The respective
  71. governments have agreed to provide you with data from a set of mobile
  72. tracking units, each capable of determining its distance from a radio
  73. signal's point of broadcast.  Armed with the information from 3 of
  74. these units, and a 2-dimensional map of the area, you are to write a
  75. program which will determine the distance and the direction of the
  76. particular transmitter from the nearest city in your area.
  77.  
  78. INPUT
  79.  
  80. The input will consist of a 2-dimensional map (using Cartesian
  81. coordinates) followed by the # of pirate signals that must be located
  82. and a corresponding # of pirate station datasets.
  83.  
  84. In the map, the data for each city will appear on a separate line.
  85. The data for each city will consist of a 15-character name followed by
  86. the city's x- and y-coordinates and a radius.  The x and y coordinates
  87. give the city's geographical centre, while the radius gives the
  88. distance from the centre of the city to the city limits (all cities
  89. may be considered circular in this problem).  There will be no more
  90. than 50 cities and the last city on the map will be located at the
  91. origin (0.0, 0.0).
  92.  
  93. Following the map is a single integer (on a line y itself) which gives
  94. the # of pirate station datasets that follow.  Each pirate station
  95. dataset will consist of nine readings on a single line, separated by
  96. spaces.  The first three readings corresponding to mobile tracking
  97. unit A, the next three to unit B, and the last three to unit C.  The
  98. first 2 readings in a set of 3 are the x and y coordinates where the
  99. mobile tracking unit itself is located while the third reading is the
  100. distance the unit determined itself to be from the source of the
  101. pirate radio station signal.  Note that all coordinates and distance
  102. values are given in kilometeres and should be stored as real #s.  The
  103. locations of the 3 mobile tracking units reporting information on the
  104. irate signal will not be collinear and will always be at least 10
  105. kilometres apart.  No city will be located more than 6000 kilometres
  106. away from the city at the origin.  You may assume only valid data will
  107. be supplied.
  108.  
  109. OUTPUT
  110.  
  111. Your program should process each pirate station dataset using the
  112. information supplied bye he 3 mobile tracking units and produce a
  113. summary line for each pirate signal which relates the source of the
  114. broadcast to the nearest town on the map.  Specifically your output
  115. should supply the distance from the illegal transmitter to the city
  116. limits (not the geographical centre) of the nearest cit, the principle
  117. compass direction of the illegal transmitter from the nearest city
  118. (North, North East, East, South East, South, South West, West, or North
  119. West), and the name of that city.
  120.  
  121. The distance should be correct within +- 0.02 of a kilometre and
  122. output to two digits of accuracy.  To determine the compass direction
  123. of the pirate transmitter from the nearest city, each of the eight
  124. principle directions should be considered to be at a centre of a 45
  125. degree arc in that direction.  Illegal transmitters which fall
  126. anywhere within a a particular arc are considered to be in that
  127. direction.  Thus if due north is at 0 degrees, a transmitter that was
  128. at an angle between 22 degrees and 67 degrees (inclusive) would be
  129. considered north east of the city while a transmitter that was at an
  130. angle between 68 degrees and 112 degrees (inclusive) would be
  131. considered east of the city.  When determining the direction of the
  132. pirate transmitter, an angle should be rounded off the nearest whole
  133. degree. 
  134.  
  135. Pirate transmitters that are located inside a city;s limits should be
  136. reported as originating from that city (no distance or directional
  137. information should be output in this case). All pirate transmitter
  138. reports should be preceded by a transmitter ID # (starting with
  139. transmitter 1).  Refer to the following example for the acceptable
  140. phrasing of your output.
  141.  
  142.  
  143. EXAMPLE
  144.  
  145. Suppose the input file consisted of the following map and mobile
  146. tracking unit readings:
  147.  
  148. --
  149.  
  150. Pleasantville   937.8      1277.34   4.9
  151. Avion           494.17    -483.06    12.7 
  152. Caniama        -803.24     1351.68   6.53
  153. Kingstons Falls-554.45    -300.0     1.82
  154. Otisburg        0.0       0.0        3.6
  155. 5
  156. 286.91 1538.6 676.989 1627.84 1450.3 1026.29 1140.4 451.47 705.152
  157. -1021.9 -1064.67 2164.66 1089.23 0.0 1796.91 993.94 -1516.17 2882.78
  158. 200.0 -295.6 824.776 -683.94 -1118.64 998.19 474.16 1729.8 2145.37
  159. -173.21 -700.2 695.308 -202.87 191.04 971.421 1407.9 525.65 1369.38
  160. 747.02 419.61 628.79 0.0 -582.19 645.469 -987.65 294.3 1300.12
  161.  
  162. --
  163.  
  164. According to the above dataset, the town of Caniama is located at
  165. (-803.24, 1351.68) and has a radius of 6.53 kilometres and there are 5
  166. pirate transmitters in the pirate station dataset.  Furthermore, in
  167. the case of pirate station #2, the mobile tracking units are reporting
  168. the following information: mobile tracking unit A, which is located at
  169. (-1021.9, -1064.67), has detected the transmission from 2164.66
  170. kilometres away; Unit B located at (1089.23, 0.0) is receiving the
  171. broadcast from 1796.91 kilometres away; and Unit C, located at
  172. (993.94, -1516.17) , is picking it up from 2882.78 kilometres away.
  173.  
  174. Your program would generate the following output for this data:
  175.  
  176. Pirate Transmitter 1 is located 354.65 kilometres South West of Pleasantville
  177. Pirate Transmitter 2 is located 524.55 kilometres South East of Caniama
  178. Pirate Transmitter 3 is located 182.27 kilometres North of Kingstons Falls
  179. Pirate Transmitter 4 is located in Avion
  180. Pirate Transmitter 5 is located 275.12 kilometres East of Otisburg.
  181.  
  182. --
  183.  
  184. All right, there is it. Remember, output has to be exactly as
  185. specified.
  186.  
  187. --Ram
  188.  
  189. me@ram.org  ||  http://www.ram.org  ||  http://www.twisted-helices.com/th
  190.     If you didn't care what happened to me, and I didn't care for you, 
  191.     we would zig zag our way through the boredom and pain occasionally 
  192.   glancing up through the rain wondering which of the buggers to blame
  193.   and watching for pigs on the wing.                     ---Pink Floyd
  194.